<?php 
    header("Content-type: text/html; charset=utf-8");
    require_once('dbconnect.inc.php');
    require_once('auth.inc.php');

    $auth = new auth();

    $auth->setDefRedir($_SERVER['PHP_SELF']);

    $user = $auth->isauth($dbh,$_COOKIE, false);

    if (!$user)
    {
        header($auth->getAuthRedir());
        $cookie = $auth->getCookie();
        setcookie($cookie['name'], $cookie['value']);
        exit();
    }
    
    
    
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

<head>
    <title>Монитор</title>
    <?php
        require_once('headers.inc.php');
    ?>
    <script src="js/alert.js" type="text/javascript"></script>
    <script src="monitor.js" type="text/javascript"></script>
    <script type="text/javascript">
    <?php
        echo 'var user_is_operator='.(($user['role'] == $auth->auth_role_user) ? 'true': 'false').";\n";
        echo 'var use_alarm='.(($feature_alarm)?'true':'false').";\n";
    ?>
    </script>
</head>
<body>

<div id="set-phase-form" title="Установить фазу">
</div>

<div id="set-prog-form" title="Установить программу">
</div>

<div id="header-mon">
<div id="title">
</div>

<div id="clock"></div>
<div id="mode-info"></div>
<?php
  if (isset($user))
  {
    echo '<div id="user-info">'.$auth->explainRole(intval($user['role'])).': <b>'.$user['name'].' ('.$user['login'].')</b></div>';
  }
?>
<input type="hidden" name="cid" value=""/>
</div>
<div id="header-mon-info">
<div id="info-pic"><img name="preview" src="img/noimage.png"/></div>
<div id="info-log">
    <div id="info-toolbar">
        <span id="sys-radio">
            <input type="radio" id="radio1" name="system" value="0"  checked="checked" /><label for="radio1">Вcе</label>
            <input type="radio" id="radio2" name="system" value="1" /><label for="radio2">Система</label>
            <input type="radio" id="radio3" name="system" value="2" /><label for="radio3">Контроллер</label>
        </span>
        <span id="filt-log">
            <input type="radio" id="radio5" name="filt" value="-1" checked="checked" /><label for="radio5">Все</label>
            <input type="radio" id="radio6" name="filt" value="1" /><label for="radio6">Состояние</label>
            <input type="radio" id="radio7" name="filt" value="2" /><label for="radio7">Ошибки</label>
        </span>
        <button id="full-log" name="full-log">Журнал</button>
    </div>
    <div id="info-table">
    </div>
</div>
</div>
<div id="content-mon">
<table id="list"></table>
</div>

<div id="bottom-mon">
    <fieldset id="disp">
        <legend id="disp-name">Диспетчерское управление</legend>
        <button id="disp-button"></button>
        <div id="phase-grp">
            <button id="phase-button">Установить фазу</button>
            <button id="cancel-phase-button">Отменить фазу</button>
        </div>
        <div id="prog-grp">
            <button id="program-button">Вызвать программу</button>
            <button id="cancel-program-button">Отменить программу</button>
        </div>
        <div id="script-grp">
            <select id="script-sel" class="ui-widget ui-state-default ui-corner-all"></select>
            <button id="script-button">Выполнить сценарий</button>
        </div>
    </fieldset>

    <button id="confirm-button">Квитирование</button>
        
    <button id="exit-button">Выход</button>    

    <div id="script-info"></div>
    
</div>

</body>
</html>
